package com.cumt.threeway.activity;

import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.cumt.threeway.R;
import com.cumt.threeway.util.ThreeWayUtil;

/**
 * Created by 胡晶晶 on 2016/5/25.
 */
public class SubmitSuggestionActivity extends FragmentActivity implements View.OnClickListener{

    private TextView mTvTitle;
    private EditText mEtContent;

    private Handler mHandler = new Handler();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pinglun);
        initView();
    }

    private void initView() {
        findViewById(R.id.btn_back).setOnClickListener(this);
        findViewById(R.id.tv_confirm).setOnClickListener(this);
        mTvTitle = (TextView) findViewById(R.id.tv_title);
        mEtContent = (EditText) findViewById(R.id.et_comment);
        mTvTitle.setText(getResources().getString(R.string.suggestion_message));
    }

    @Override
    public void onClick(View v) {
        if(v == null) {
            return;
        }
        switch (v.getId()) {
            case R.id.btn_back:
                finish();
                break;
            case R.id.tv_confirm:
                if(TextUtils.isEmpty(mEtContent.getText().toString())) {
                    ThreeWayUtil.getInstance().showToast(this, getResources().getString(R.string.comment_error));
                } else {
                    ThreeWayUtil.getInstance().showToast(this, getResources().getString(R.string.suggestion_success));
                    mHandler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                           finish();
                        }
                    },600);
                }
                break;
        }
    }
}
